package ru.simplemaps.osmapi.common;

import junit.framework.TestCase;

import java.util.Arrays;
import java.util.Collection;

/**
 * @author enaku_adm
 * @since 23.07.2010 11:32:30
 */
public class BBoxTestCase extends TestCase {

    public void testComplexMinus() {
        BBox b1 = new BBox(0, 0, 10, 10);

        BBox m1 = new BBox(0, 0, 3, 3);
        BBox m2 = new BBox(7, 7, 10, 10);

        Collection<BBox> result = b1.minus(Arrays.asList(m1, m2));

        assertEquals(result.size(), 5);
        assertTrue(result.contains(new BBox(0, 3, 3, 10)));
        assertTrue(result.contains(new BBox(3, 0, 10, 3)));
        assertTrue(result.contains(new BBox(3, 3, 7, 7)));
        assertTrue(result.contains(new BBox(3, 7, 7, 10)));
        assertTrue(result.contains(new BBox(7, 3, 10, 7)));
    }

    public void testSimpleMinus() {
        BBox b1 = new BBox(0, 0, 10, 10);
        Collection<BBox> result = b1.minus(new BBox(3, 3, 6, 6));

        assertEquals(result.size(), 8);
        assertTrue(result.contains(new BBox(0, 0, 3, 3)));
        assertTrue(result.contains(new BBox(0, 3, 3, 6)));
        assertTrue(result.contains(new BBox(0, 6, 3, 10)));
        assertTrue(result.contains(new BBox(3, 0, 6, 3)));
        assertTrue(result.contains(new BBox(6, 0, 10, 3)));
        assertTrue(result.contains(new BBox(6, 3, 10, 6)));
        assertTrue(result.contains(new BBox(3, 6, 6, 10)));
        assertTrue(result.contains(new BBox(6, 6, 10, 10)));
    }
}
